package com.pzy.controller.interceptor;

import com.pzy.controller.results.Results;
import com.pzy.system.exception.BusinessException;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Component
@ControllerAdvice
public class ProjectExceptionAdivce {

    @ExceptionHandler(BusinessException.class)
    @ResponseBody
    public Results doBusinessException(BusinessException e){
        return new Results(e.getCode(),e.getMessage());
    }
}
